home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / scsiDiskBoot / sun3.md / dev.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-15  |  3.4 KB  |  110 lines

  1. /*
  2.  * dev.c --
  3.  *
  4.  *    Excerpts from the dev module in the kernel.
  5.  * Copyright 1985 Regents of the University of California
  6.  * All rights reserved.
  7.  */
  8.  
  9. #ifdef notdef
  10. static char rcsid[] = "$Header: /sprite/src/kernel/dev/sun3.md/RCS/devInit.c,v 8.3 89/05/24 07:50:56 rab Exp $ SPRITE (Berkeley)";
  11. #endif 
  12.  
  13. #include "sprite.h"
  14. #include "devInt.h"
  15. #include "vmSunConst.h"
  16.  
  17.  
  18.  
  19.  
  20. /*
  21.  *----------------------------------------------------------------------
  22.  *
  23.  * Dev_Config --
  24.  *
  25.  *    Call the initialization routines for various controllers and
  26.  *    devices based on configuration tables.  This should be called
  27.  *    after the regular memory allocater is set up so the drivers
  28.  *    can use it to configure themselves.
  29.  *
  30.  * Results:
  31.  *    None.
  32.  *
  33.  * Side effects:
  34.  *    Call the controller and device initialization routines.
  35.  *
  36.  *----------------------------------------------------------------------
  37.  */
  38. void
  39. Dev_Config()
  40. {
  41.     int memoryType;        /* This is ultimatly for the page table
  42.                  * type field used to map in the device */
  43.     Boolean mapItIn;        /* If TRUE we need to map the device into
  44.                  * kernel virtual space */
  45.     register DevConfigController *cntrlrPtr;
  46.  
  47.     cntrlrPtr = &devCntrlr[0];
  48.     /*
  49.      * The following makes sure that the physical address for the
  50.      * controller is correct, and then maps that into the kernel's virtual
  51.      * address space (if it hasn't already been done by the Boot PROM).
  52.      * There are two things happening here.  First, each device has
  53.      * its own physical address on its own kind of bus - A device may
  54.      * think it's in Multibus Memory, or VME bus 16 bit data 16 bit address,
  55.      * or some other permutation.  For Multibus Memory devices, like
  56.      * the SCSI controller, Multibus memory is the low megabyte of
  57.      * the physical addresses, with Multibus I/O being the last 64K
  58.      * of this first Meg.  Furthermore, the Boot PROM maps this low
  59.      * meg of physical memory into the 16'th Meg of the kernel's virtual
  60.      * address space.  All that needs to be done is imitate this mapping
  61.      * by adding the MULTIBUS BASE to the controller address and the
  62.      * controller can forge ahead.
  63.      * It's more complicated for VME devices.  There are six subsets
  64.      * of address/data spaces supported by the VME bus, and each one
  65.      * belongs to a special range of physical addresses and has a
  66.      * corresponding "page type" which goes into the page table.
  67.      * Furthermore, we arn't depending on the boot PROM and so once
  68.      * the correct physical address is gen'ed up we need to map it
  69.      * into a kernel virtual address that the device driver can use.
  70.      */
  71.     switch(cntrlrPtr->space) {
  72.         case DEV_VME_D16A16:
  73.         /*
  74.          * The high 64K of the VME address range is stolen for the
  75.          * 16 bit address subset.
  76.          */
  77.         mapItIn = TRUE;
  78.          memoryType = 2;
  79.         cntrlrPtr->address += 0xFFFF0000;
  80.         break;
  81.         case DEV_VME_D16A24:
  82.         /*
  83.          * The high 16 Megabytes of the VME address range is stolen
  84.          * for the 24 bit address subset.
  85.          */
  86.         mapItIn = TRUE;
  87.          memoryType = 2;
  88.         cntrlrPtr->address += 0xFF000000;
  89.         break;
  90.         case DEV_OBIO:
  91.         mapItIn = FALSE;
  92.         memoryType = 1;
  93.         break;
  94.     }
  95. #ifdef sun2
  96.                     if (mapItIn && cntrlrPtr->address >= 0xFF800000) {
  97.                         memoryType = 3;
  98.                     } else {
  99.                         memoryType = 2;
  100.                     }
  101. #endif
  102.     if (mapItIn) {
  103.         cntrlrPtr->address =
  104.         (int)VmMach_MapInDevice((Address)cntrlrPtr->address,memoryType);
  105.     }
  106.          (*cntrlrPtr->initProc)(cntrlrPtr);
  107. }
  108.  
  109.  
  110.